#!/bin/bash
i=1
sum=0
bin_dir=$HOME/git/p2pcpp/build/bin
cd $bin_dir

sudo ulimit -n 2000
ulimit -n 2000

echo "max open files:`ulimit -n`"

ssh vi@172.16.10.8 "mkdir -p ~/git/log/"
mkdir -p ~/git/log/

log_name=statistic_`date +%Y_%m_%d`.log
log_full_name=/var/tmp/$log_name

touch $log_full_name

ssh vi@172.16.10.8 "date >>  $log_full_name"
date >>  $log_full_name

cd ~/git/p2pcpp/build/bin && ./p2pcpp -t suite_udp_multiple/case_connect_statistic_clear >> $log_full_name 

sleep 3


while [ $i -le 100000 ]
do
    echo  "------------------------------------------------------"    >> $log_full_name
    echo  "`date +%Y-%m-%d_%H:%M:%S` try new time."    >> $log_full_name
    let sum=sum+$i
    let i++
    ssh vi@172.16.10.8 "cd ~/git/p2pcpp/build/bin && ./p2pcpp -t suite_udp_multiple/case_ask_for_nat_connection >> $log_full_name"   &
    cd ~/git/p2pcpp/build/bin && ./p2pcpp -t suite_udp_multiple/case_ask_for_nat_connection >> $log_full_name      &
    sleep 600
done

